package com.zcoj.service;

import com.zcoj.core.model.ApiResponse;
import com.zcoj.core.model.PageData;
import com.zcoj.core.model.PageWrap;
import com.zcoj.pojo.Dto.Discussion;
import com.zcoj.pojo.Vo.*;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.lang.NonNull;

import java.util.List;

/**
 * Service定义
 * @author 剩xia的盛夏
 * @date 2023/02/24 16:16
 */
@CacheConfig(cacheNames = "DiscussionService")
public interface DiscussionService {

    /**
     * 创建
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "DiscussionService",allEntries = true)
    ApiResponse create(Discussion discussion);

    /**
     * 主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "DiscussionService",allEntries = true)
    Integer deleteById(Integer id);

    /**
     * 批量主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "DiscussionService",allEntries = true)
    void deleteByIdInBatch(List<Integer> ids);

    /**
     * 主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "DiscussionService",allEntries = true)
    Integer updateById(Discussion discussion);

    /**
     * 批量主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "DiscussionService",allEntries = true)
    void updateByIdInBatch(List<Discussion> discussions);

    /**
     * 主键查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findById'")
    Discussion findById(Integer id);


    @Cacheable(key = "#p0.toString()+'findByIdVo'")
    DiscussionVO findByIdVo(Integer id);

    /**
     * 条件查询单条记录
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()")
    Discussion findOne(Discussion discussion);

    @CacheEvict(key = "#p0.toString()")
    Boolean clickLike(Integer id);

    /**
     * 条件查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @Cacheable(key = "#p0.toString()+'findList'")
    List<Discussion> findList(Discussion discussion);
  
    /**
     * 分页查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @Cacheable(key = "#p0.toString()+'findPage'")
    PageData<Discussion> findPage(PageWrap<Discussion> pageWrap);



    @Cacheable(key = "#p0.toString()+'findPageVo'")
    PageData<Discussion> findPageVo(PageWrap<Discussion> pageWrap);



    Boolean reportDiscussion(DiscussionReportVO discussionReportVO);


    @Cacheable(key = "#p0.toString()",value = "CommentAndReplies")
    List<CommentVO> getDiscussionCommentAndReplies(@NonNull DiscussionRequestVo discussionRequestVo);



    @CacheEvict(key = "#p0.toString()",value = "CommentAndReplies")
    Boolean submitDiscussionComment(@NonNull SubDiscussionCommentVO subDiscussionCommentVO);


    @CacheEvict(key = "#p0.toString()",value = "CommentAndReplies")
    Boolean submitCommentReply(@NonNull CommentReplyVO commentReplyVO);
    /**
     * 条件统计
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    long count(Discussion discussion);
}
